package cn.fintecher.gis.web;


import cn.fintecher.gis.annotation.CurrentOperator;
import cn.fintecher.gis.entity.RestsInfo;
import cn.fintecher.gis.model.request.RestsInfoRequest;
import cn.fintecher.gis.model.session.SessionModel;
import cn.fintecher.gis.service.RestsInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/api/restsInfoController")
@Api(value = "restsInfoController", description = "其他项目信息")
public class RestsInfoController {

    @Autowired
    private RestsInfoService restsInfoService;

    @PostMapping("/addRestsInfo")
    @ApiOperation(value = "其他项目信息添加", notes = "其他项目信息添加")
    public ResponseEntity<Void> addRestsInfo(@RequestBody RestsInfoRequest request,
                                             @ApiIgnore @CurrentOperator SessionModel model) throws Exception {
        restsInfoService.add(request, model);
        return ResponseEntity.ok().build();
    }

    @GetMapping("/getRestsInfoById/{id}")
    @ApiOperation(value = "根据id查询对应的信息", notes = "根据id查询对应的信息")
    public ResponseEntity<RestsInfo> getRestsInfoById(@PathVariable String id) {
        RestsInfo restsInfo = restsInfoService.getInfoById(id);
        return ResponseEntity.ok().body(restsInfo);
    }
}
